package com.zy.mall.service;

import com.zy.mall.dao.AdminDao;
import com.zy.mall.dao.AdminDaoImpl;
import com.zy.mall.model.Admin;
import com.zy.mall.model.bo.AdminChangeBo;
import com.zy.mall.model.bo.AdminLoginBo;
import com.zy.mall.model.bo.AdminSearchBo;

import java.util.List;

public class AdminServiceImpl implements AdminService {

    private AdminDao adminDao = new AdminDaoImpl();

    public Admin login(AdminLoginBo loginBo) {
        Admin admin = new Admin();
        admin.setEmail(loginBo.getEmail());
        admin.setPwd(loginBo.getPwd());
        return adminDao.login(admin);
    }

    @Override
    public List<Admin> allAdmins() {
        return adminDao.allAdmins();
    }

    @Override
    public List<Admin> getSearchAdmins(AdminSearchBo searchBo) {
        Admin admin = new Admin();
        admin.setEmail(searchBo.getEmail());
        admin.setNickname(searchBo.getNickname());
        return adminDao.getSearchAdmins(admin);
    }

    @Override
    public void addAdmin(Admin admin) {
        adminDao.addAdmin(admin);
    }

    @Override
    public boolean deleteAdmins(String id) {
        return adminDao.deleteAdmins(id);
    }

    @Override
    public boolean updateAdmins(Admin admin) {
        return adminDao.updateAdmins(admin);
    }


    @Override
    public Admin getAdminsInfo(String id) {
        return adminDao.getAdminsInfo(id);
    }

    @Override
    public int changePwd(AdminChangeBo changeBo) {
        return adminDao.changePwd(changeBo);
    }


}
